def add():
    arg = 1
    ilist = []
    while arg > 0:
        arg = int(input("请输入你要计算的数字(输入0结束输入)："))
        ilist.append(arg)
    return sum(ilist)

def minus():
    x = int(input("请输入减数："))
    y = int(input("请输入被减数："))
    result = x - y
    return result

def multiply():
    result = 1
    arg = 1
    args = []
    while arg != 0:
        args.append(arg)
        arg = int(input("请输入你要计算的数字(输入0结束输入)："))
    for i in args:
        result *= i
    return result

def divide():
    x = int(input("请输入除数："))
    y = int(input("请输入被除数："))
    if y == 0:
        print("被除数不能为0，请重新操作！")
    result = x / y
    return result

def menu():
    num = int(input("1.加法\n2.减法\n3.乘法\n4.除法\n5.退出\n请输入你要进行的操作:"))
    if num == 1:
        print("这些数字之和为{}".format(add()))
    elif num == 2:
        print("这两个数的差为{}".format(minus()))
    elif num == 3:
        print("这些数之积为{}".format(multiply()))
    elif num == 4:
        print("这两个数的商为{}".format(divide()))
    elif num == 5:
        exit()
    else:
        print("请输入正确的数字！")

menu()
